package ch.fhnw.qualiscan.application.components;

import ch.fhnw.qualiscan.Config;
import ch.fhnw.qualiscan.core.LayoutComponent;
import ch.fhnw.qualiscan.core.helpers.SessionHelper;

import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.CustomLayout;
import com.vaadin.ui.VerticalLayout;

import eu.livotov.tpt.i18n.TM;

public class SignUpBox extends LayoutComponent {

	private static final long serialVersionUID = -5590684213935588576L;
	
	public SignUpBox() {}

	@Override
	public void buildComponent() {		
		
		SessionHelper session = new SessionHelper();
		
		if(session.isUserSessionSet() == false) {
			CustomLayout custom = new CustomLayout("custom/sidebarComponent");
			addComponent(custom);
			
			custom.addComponent(textHelper.boxTitle(TM.get("signup.title")), "title");
			Button getAccount = new Button(TM.get("signup.button"));
			
			VerticalLayout boxContent = new VerticalLayout();
			boxContent.addComponent(textHelper.p(TM.get("signup.desc")));
			boxContent.addComponent(getAccount);
			
			custom.addComponent(boxContent, "content");
			
			getAccount.addListener(new ClickListener() {
				private static final long serialVersionUID = 1L;
				public void buttonClick(ClickEvent event) {
					urlLib.setPage("NewAccount");
				}
			});
			getAccount.setIcon(Config.ICON_ADDUSER);
		}
	}
	
}
